package com.iqiyi.pps.epg.core.dao.ticket;

import com.iqiyi.pps.epg.api.model.web.ticket.TTicketLog;
import com.iqiyi.pps.epg.core.dao.base.BaseDao;
import com.iqiyi.pps.epg.core.model.ticket.TicketLog;
import com.iqiyi.pps.epg.core.utils.DateTimeUtil;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by karkarrotxu on 2017/8/29.
 */
@Component
public class TicketLogDao extends BaseDao<TicketLog> {
    public TTicketLog transToThrift(TicketLog tempData) {
        TTicketLog entity = new TTicketLog();
        entity.setId(tempData.getId());
        entity.setDataId(tempData.getDataId());
        entity.setUser(tempData.getUser());
        entity.setType(tempData.getType());
        entity.setDescr(tempData.getDescr());
        entity.setAddTime(DateTimeUtil.transLongFormat(tempData.getAddTime().getTime()));
        return entity;
    }

    public List<TTicketLog> transToTList(List<TicketLog> dataList) {
        List<TTicketLog> resultList = new ArrayList<>();
        TTicketLog entity = null;
        for (TicketLog tempData : dataList) {
            entity = transToThrift(tempData);
            resultList.add(entity);
        }
        return resultList;
    }
}
